package com.ziroom.zifamily.zfms.logic.base;

import com.ziroom.zifamily.zfms.mapper.base.entity.LoginLogEntity;
import com.ziroom.zifamily.zfms.service.base.LoginService;
import com.ziroom.zifamily.zfms.pojo.obj.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 登录逻辑类
 * <p>
 * <PRE>
 * <BR>    修改记录
 * <BR>-----------------------------------------------
 * <BR>    修改日期         修改人          修改内容
 * </PRE>
 *
 * @author cuiyh9
 * @version 1.0
 * @Date Created in 2018年11月24日 17:35
 * @since 1.0
 */
@Component
public class LoginLogic {

    @Autowired
    private LoginService logicService;

    /**
     * 记录登录日志
     * @param userInfo
     * @param remoteIp
     */
    public void recordLoginLog(UserInfo userInfo, String remoteIp) {
        LoginLogEntity loginLogEntity = LoginLogEntity.builder()
                .empCode(userInfo.getSystemCode())
                .empName(userInfo.getNickName())
                .loginTime(new Date())
                .loginIp(remoteIp).build();
        logicService.recordLoginLog(loginLogEntity);
    }

}
